package com.gxz.boot;

import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Component
public class Bean1 extends BaseBean {

    public static void main(String[] args) throws InterruptedException {
        Map<String, Integer> map = new ConcurrentHashMap();
        map.put("val", 0);
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                int v = map.get("val");
                v++;
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                map.put("val", v);
            }).start();
        }
        Thread.sleep(3000);
        System.out.println(map);
    }

}
